package com.neutech.solar.client;

import com.neutech.solar.entity.AbstractFrame;
import com.neutech.solar.entity.Background;
import com.neutech.solar.entity.Planet;
import com.neutech.solar.entity.Sun;

import java.awt.*;
import java.util.List;
import java.util.ArrayList;
import java.util.Random;
/**
 * @Author DELL
 * @Date 2021/1/26 17:04
 * @Version 1.0
 */
public class SolarSystemClient extends AbstractFrame {

    public Background bg = new Background();
    public Sun sun = new Sun();
    Planet Mercury = new Planet(sun,"Mercury",0.387,0.2056,88,"水星");
    Planet Venus = new Planet(sun,"Venus",0.72,0.0068,225,"金星",false,true);
    Planet Earth = new Planet(sun,"Earth",1,0.0167,365,"地球");
   // Planet moon = new Planet(Earth,"smallPlanet",0.3,0.0,365/12,"");

    Planet Mars = new Planet(sun,"Mars",1.52,0.0934,687,"火星");
    Planet Jupiter = new Planet(sun,"Jupiter",5.2,0.0489,4330,"木星");
    Planet Saturn = new Planet(sun,"Saturn",9.54,0.0557,10832,"土星");
    Planet Uranus = new Planet(sun,"Uranus",19.218,0.0444,30777,"天王星");
    Planet Neptune = new Planet(sun,"Neptune",30.06,0.0112,60328,"海王星");
    Planet Halley = new Planet(sun,"Halley",17.8,0.967,27485,"哈雷彗星");

    List<Planet> planets = new ArrayList<>();
    Random r = new Random();
    {
        for (int i = 0; i < 1000; i++) {
            double AU = r.nextDouble() * 2 + 2.0;
//            double e = r.nextDouble();
            int T = r.nextInt(3300)  + 700;
            Planet smallPlanet = new Planet(sun,"smallPlanet",AU,0.0,T,"",true);
            planets.add(smallPlanet);
        }
    }


    public SolarSystemClient(){
        super.init("太阳系八行星运行系统");
    }

    @Override
    public void paint(Graphics g) {
        bg.draw(g);
        sun.draw(g);
        Mercury.draw(g);
        Venus.draw(g);
        Earth.draw(g);
        //moon.draw(g);
        Mars.draw(g);

        // 小行星带
        for(Planet smallPlanet : planets){
            smallPlanet.draw(g);
        }

        Jupiter.draw(g);
        Saturn.draw(g);
        Uranus.draw(g);
        Neptune.draw(g);

        Halley.draw(g);

    }

    public static void main(String[] args) {
        new SolarSystemClient();
    }
}